const authorityFormatMenu = (menu, keys) => {
  const result = []
  menu.forEach((item) => {
    if (!item.children) {
      if (keys?.includes(item.key)) {
        result.push(item)
      }
    } else {
      const newItem = { ...item, children: [] }
      item.children.forEach((child) => {
        if (keys?.includes(child.key)) {
          newItem.children.push(child)
        }
      })
      if (newItem.children.length) result.push(newItem)
    }
  })
  return result
}
export default authorityFormatMenu
